library(tidyverse)
library(readxl)
path = "files/Excel Challenge 14th July.xlsx"
input = read_xlsx(path, range = "B2:D8")
test = read_xlsx(path, range = "F2:L8")
result = input %>%
separate_rows(c(Customers, Orders), sep = "; ") %>%
pivot_wider(names_from = Customers, values_from = Orders) %>%
mutate(across(-c(1), ~as.numeric(.)))
all.equal(result, test)
#> [1] TRUECrispo - Excel Challenge 28 2024
excel-challenges
weekly-exercises
Easy Sunday Excel Challenge

Challenge Description
Easy Sunday Excel Challenge
⭐ Problem Solution Date Customers Orders Aiden
Solutions
Logic:
Reshapes the data to the grain required by the task
Builds the intermediate helper columns that drive the final answer
Strengths:
- The R solution stays compact and mirrors the workbook logic closely.
Areas for Improvement:
- The code assumes the workbook layout and named ranges remain stable.
Gem:
- The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd
path = "files/Excel Challenge 14th July.xlsx"
input = pd.read_excel(path, usecols="B:D", skiprows=1, nrows = 6)
test = pd.read_excel(path, usecols="F:L", skiprows=1, nrows = 6)
test.columns = test.columns.str.replace(".1", "")
result = input.assign(Customers=input.Customers.str.split("; "),
Orders=input.Orders.str.split("; ")) \
.explode(["Customers", "Orders"]) \
.pivot(index="Date", columns="Customers", values="Orders") \
.reset_index()
result[result.columns[1:]] = result[result.columns[1:]].apply(pd.to_numeric).fillna(" ")
result.columns.name = None
test = test.fillna(" ")
print(result.equals(test)) # TrueLogic:
Reads the workbook range needed for the challenge
Reshapes the data to the grain required by the task
Builds the intermediate helper columns that drive the final answer
Strengths:
- The Python version keeps the same rule in a direct pandas-oriented workflow.
Areas for Improvement:
- As with the R version, any workbook layout change would require small adjustments.
Gem:
- The implementation stays close to the stated challenge instead of adding unnecessary complexity.
Difficulty Level
This task is moderate:
It combines familiar Excel-style logic with at least one non-trivial reshape, grouping, or parsing step.
The answer depends on getting the output layout exactly right.